<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script
      src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.40/vue.global.js"
      type="application/javascript"
    ></script>
  </head>
  <body>
    <div id="app">
      <!-- v-if运行成本比较高，常用于初始化 -->
      <template v-if="type==='a'">
        <div>
          <h1>h1</h1>
          <h2>h2</h2>
        </div>
      </template>
      <!-- <div v-if="type==='a'">12312312</div> -->
      <!-- <hr /> -->
      <!-- <div v-else-if="type==='b'">b</div> -->
      <!-- <div v-else-if="type==='c'">c</div> -->
      <!-- <div v-else>NOT a/b/c</div> -->
      <!-- v-show适合频繁的操作显示或者隐藏 -->
      <!-- <div class="show" v-show="type==='a'">show</div> -->

      <template v-if="loginType==='username'">
        <label>用户名</label>
        <input type="text" placeholder="请输入用户名:" />
      </template>
      <template v-else>
        <label for="inp">邮箱</label>
        <input type="text" placeholder="请输入邮箱地址:" />
      </template>
      <!-- v-if后面可以接上js表达式 -->
      <div v-if="Math.random()>0.5">随机数大于0.5</div>
      <div v-else>随机数小于或者等于于0.5</div>
    </div>
    <script>
      const app = Vue.createApp({
        data() {
          return {
            msg: "hello world",
            type: "a",
            loginType: "username",
          };
        },
      });
      const vm = app.mount("#app");
    </script>
  </body>
</html>
